package com.hdax.dm.controller;

import com.hdax.dm.base.DmArea;
import com.hdax.dm.dto.IndexFloorDto;
import com.hdax.dm.dto.ItemSearchResultDto;
import com.hdax.dm.item.Item;
import com.hdax.dm.item.ItemType;
import com.hdax.dm.service.ItemService;
import com.hdax.dm.service.ItemTypeService;
import com.hdax.dm.utils.response.CommonResponse;
import com.hdax.dm.utils.response.ResponseUtils;
import com.hdax.dm.vo.ItemSearchVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(path = "/list")
public class ListController {

    @Autowired
    private ItemTypeService itemTypeService;

    @Autowired
    private ItemService itemService;
    //城市查询
    @PostMapping(path = "/querycity")
    public CommonResponse<List<DmArea>> querycity(){

        return itemTypeService.area();
    }
    //分类查询
    @PostMapping(path = "/sortgoods")
    public CommonResponse<List<ItemType>> sortgoods(@RequestBody Map<String,String> map){
        String parent =map.get("parent");

        String param = map.get("param");
        return itemTypeService.linenavs(parent,param);
    }
    //查询列表内容
    @PostMapping(path = "/querygoodsinfos")
    public CommonResponse<ItemSearchResultDto> querygoodsinfos(@RequestBody ItemSearchVo vo) throws IOException {

        ItemSearchResultDto dto = itemService.querygoodsinfos(vo);

        return ResponseUtils.returnSuccess(dto);
    }
    //猜你喜欢内容
    @PostMapping(path = "/guesslike")
    public CommonResponse<List<IndexFloorDto.FloorItems>> guesslike(@RequestBody Map<String,String> map){

        String type1Id = map.get("itemTypeId");

        return itemService.senioritys(Long.valueOf(type1Id));
    }


}
